package com.maycurobj.repository.oa;

import com.maycurobj.entity.oa.OASuperiorEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 取OA员工、上级工号信息
 */
@Repository
public interface ObtainShangjiRepository extends JpaRepository<OASuperiorEntity,String> {
    @Query(nativeQuery = true,value = "SELECT HRMRESOURCE.WORKCODE AS workcode,t.SHANGJI AS shangji FROM HRMRESOURCE,(SELECT a.WORKCODE AS shangji,a.id AS shangjiid,b.WORKCODE,b.id FROM HRMRESOURCE a LEFT JOIN HRMRESOURCE b ON a.id = b.managerid WHERE b.STATUS IN ( 1, 0 ) ) t WHERE HRMRESOURCE.STATUS IN ( 1, 0 ) AND t.ID = HRMRESOURCE.id and t.WORKCODE is not  null")
    List<OASuperiorEntity> getSuperior();

}
